import 'dart:convert';

import 'package:rfid/main.dart';

String? websocket = "";

String checkRfid() {
  Map<String,dynamic> data = {
    "cmd": "rfid_hf_check",
  };
  if(settingEntity.isUltra!){
    data['cmd'] = "rfid_uhf_check";
  }
  return json.encode(data);
}

String inventoryUhfRfid({required String readerIp,required String ant, required int count , bool includeTid = false}) {
  Map<String,dynamic> data = {
    "cmd": "rfid_uhf_scan",
    "data": {
      "reader":readerIp,
      "ants":ant,
      "count":count,
      "include_tid": includeTid,
    }
  };
  return json.encode(data);
}
String inventoryHfRfid({required String readerIp,required String ant, required int count,int? blockStart = 0,int? blockCount = 3,}) {
  Map<String,dynamic> data = {
    "cmd": "rfid_hf_scan",
    "data": {
      "reader":readerIp,
      "ants":ant,
      "count":count,
      "read_block": true,
      "block_start": blockStart,
      "block_count": blockCount,
    }
  };
  return json.encode(data);
}

String checkLock() {
  Map<String,dynamic> data = {
    "cmd": "locker_check",
  };
  return json.encode(data);
}

String lockOpen({required String addr, required String no}) {
  Map<String,dynamic> data = {
    "cmd": "locker_open",
    "data": {
      "addr": addr,
      "no": no
    }
  };
  return json.encode(data);
}

String lockQuery({required String addr}) {
  Map<String,dynamic> data = {
    "cmd": "locker_query",
    "data": {
      "addr": addr,
    }
  };
  return json.encode(data);
}

String checkReader() {
  Map<String,dynamic> data = {
    "cmd": "card_reader_check",
  };
  return json.encode(data);
}

String m1Inventory() {
  Map<String,dynamic> data = {
    "cmd": "card_reader_m1_inventory",
  };
  return json.encode(data);
}
String icrInventory() {
  Map<String,dynamic> data = {
    "cmd": "card_reader_icr_inventory",
  };
  return json.encode(data);
}

String readReaderBlock({required int no}) {
  Map<String,dynamic> data = {
    "cmd": "card_reader_m1_inventory",
    "data": {
      "no": no
    }
  };
  return json.encode(data);
}

